import 'dart:io';

import 'package:palmf_hid/common/entities/response/base_response.dart';
import 'package:palmf_hid/common/utils/net/http_util.dart';
import 'package:palmf_hid/common/utils/utils.dart';
import 'package:palmf_hid/common/values/values.dart';

class AppAPI {
  ///检查更新
  static Future<CheckUpdate?> getUpdateInfo(bool show) async {
    if (show) {
      MyLoadingUtil.showLoading();
    }
    //1 安卓 2 ios
    String deviceType = "1";
    if (Platform.isIOS) {
      deviceType = "2";
    }
    String appType = "palmf_hid";
    var response = await HttpUtils.get(
      '/api/sysAppUpdateInfo/get.json',
      queryParameters: {
        "token": ApiConstants.tokenV,
        "deviceType": deviceType,
        "appType": appType
      },
    );
    if (show) {
      MyLoadingUtil.hideLoading();
    }
    MyLogUtil().i(response.data);
    BaseResponse responseData = BaseResponse.fromJson(response.data);
    if (null != responseData.data) {
      return CheckUpdate.fromJson(responseData.data);
    } else {
      return null;
    }
  }
}
